html <asp: 。。。/> 里如何实现定宽Column?谢谢!
来源:百度知道 编辑:UC知道 时间:2024/06/24 12:50:56
请教“。。。”处 如何实现列的定宽? 比如Width="678px"
<asp:GridView ID="gvBookSort" runat="server" AutoGenerateColumns="False"
CellPadding="4" Font-Size="9pt" ForeColor="#333333" HorizontalAlign="Center" Width="678px" OnRowDataBound="gvBookSort_RowDataBound" AllowPaging="True" OnPageIndexChanging="gvBookSort_PageIndexChanging">
<Columns>
<asp:BoundField HeaderText="No." />
<asp:BoundField DataField="comm" HeaderText="Comments" ItemStyle-Width="200px"/ />
</Columns>
<HeaderStyle BackColor="#000000" Font-Bold="False" ForeColor="White" />
</asp:GridView></td>
<
<asp:GridView ID="gvBookSort" runat="server" AutoGenerateColumns="False"
CellPadding="4" Font-Size="9pt" ForeColor="#333333" HorizontalAlign="Center" Width="678px" OnRowDataBound="gvBookSort_RowDataBound" AllowPaging="True" OnPageIndexChanging="gvBookSort_PageIndexChanging">
<Columns>
<asp:BoundField HeaderText="No." />
<asp:BoundField DataField="comm" HeaderText="Comments" ItemStyle-Width="200px"/ />
</Columns>
<HeaderStyle BackColor="#000000" Font-Bold="False" ForeColor="White" />
</asp:GridView></td>
<
设置行高 Height="100px"
需要替换“...”的需要使用方法截取。
<ItemTemplate>
<%# StringSub(Eval("Comments").ToString(), "180") %>
</ItemTemplate>
后台方法:
public string StringSub(string str, string num)
{
string reststr = str;
if (str != null || str != "")
{
if (str.Length > Convert.ToInt32(num))
{
reststr = str.Substring(0, Convert.ToInt32(num)) + "...";
}
}
return reststr;
}
希望能够帮到你,呵呵。
没看明白 不知道你要设置什么的宽度
在GridView里加RowStyle-Height="100px"